import { MixMtEntity } from '@/pages/create/createContent/blocks/mix/store'
import { PlanEntity } from '@/pages/create/createContent/blocks/mix/interface'
import requestMeeting, { request } from '@/plugins/axios'

/**混音*/
export const fetchMixDetail = async (is_templete: boolean, pre_key: string, id: string) =>
	request<MixMtEntity>({
		url: is_templete ? `/personal_templates/${pre_key}/premixs/${id}` : `/meetings/${pre_key}/premixs/${id}`,
		method: 'get',
	}).then((res) => res)
export const fetchMixList = async (is_templete: boolean, pre_key: string) =>
	requestMeeting<PlanEntity>({
		url: is_templete ? `/personal_templates/${pre_key}/premixs?count=0` : `/meetings/${pre_key}/premixs?count=0`,
		method: 'get',
	}).then((res) => res)
export const fetchDelMix = async (is_templete: boolean, pre_key: string, id: string) =>
	requestMeeting({
		url: is_templete ? `/personal_templates/${pre_key}/premixs/${id}` : `/meetings/${pre_key}/premixs/${id}`,
		method: 'DELETE',
	}).then((res) => res)
export const fetchSaveMix = async (is_templete: boolean, pre_key: string, params: Partial<MixMtEntity>) =>
	requestMeeting({
		url: is_templete ? `/personal_templates/${pre_key}/premixs` : `/meetings/${pre_key}/premixs`,
		method: 'post',
		data: params,
	}).then((res) => res)
export const fetchUpdateMix = async (is_templete: boolean, pre_key: string, id: string, params: Partial<MixMtEntity>) =>
	requestMeeting({
		url: is_templete ? `/personal_templates/${pre_key}/premixs/${id}` : `/meetings/${pre_key}/premixs/${id}`,
		method: 'post',
		data: params,
	}).then((res) => res)

export const fetchCreateMeetingPlanList = async (
	url: string,
	params: {
		order?: number
		count?: number
		start?: number
	}
) =>
	requestMeeting<PlanEntity>({
		url: url,
		method: 'get',
		params: params,
	}).then((res) => res)
